package gui;

import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.border.BevelBorder;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;

import data.ActionList;
import data.ProcList;
import data.model.Action;
import data.model.Processor;

public class ProcessorPanel extends JPanel {

private static JTextArea procText;
	
	
	public ProcessorPanel() {
		Border border = BorderFactory.createTitledBorder(BorderFactory.createBevelBorder( BevelBorder.LOWERED),
				"Processors",TitledBorder.CENTER,TitledBorder.TOP);
		setBorder(border);
		procText = new JTextArea();
		add(procText);
		
		updateProcs();
	}
	
	/**
	 * refresh list of actions from data
	 */
	public static void updateProcs()
	{
		Object[] acts = ProcList.getList();
		
		StringBuilder sb = new StringBuilder("");
		
		for(Object o : acts)
		{
			if(o != null)
				sb.append(((Processor) o).getProcName() + "\n");
		}
		
		procText.setText(sb.toString());
	} 
	
}
